<?php
require 'includes/config.php';
require 'includes/auth.php';
require 'includes/sanitize.php';
$message = "default";
$data = sanitize($_GET);
if ($_GET['submit'] && isset($data['username'])) {
	// Get info from backend about user
	$request = new makeRequest($backend.'api.php?method=user&username='.$data['username'], 'GET');
	$tmp = $request->makeRequest();
	$rbody = $tmp[0];
	$http_code = $tmp[1];
	$obj = json_decode($rbody);
	// Check for errors
	if($http_code == 200 && $obj[0]->{'username'} != ""){
		// Link to user profile
		$message = '<a href="profile.php?status=true&username='.$obj[0]->{'username'}.'">Go to profile '
		.$obj[0]->{'username'}.'</a>';
	}else{
		$message = "No user found";
	}
}

require 'includes/header.php';
require 'includes/topmenu.php';
echo '<div id="kaka">';
require 'includes/sidemenu.php'
?>
<div id="content"><?php
/* Content shown on page */
if($message != "default"){
	echo $message;
}
?>
<p>Search for a username:</p>
<table>
	<form method="get" action="<?php echo $PHP_SELF; ?>">
	<tr>
		<td>Username:<br />
		</td>
		<td><input type="text" name="username"
			value="<?php echo $username; ?>" /><br />
		</td>
	</tr>
	<tr>
		<td><input type="submit" Value="Search" name="submit" />
	
	</form>
	</td>
	<td></td>
	</tr>
</table>
<?php

require 'includes/footer.php';
?>